using System;
using System.Data;

using Wicresoft.Common;

namespace Wicresoft.Messages.Entity
{
    [Table("Module", "", "Wicresoft.Messages.ConnectionString")]
    public class Module : Info
    {
        #region SQL column name consts
        public const string SQLCOL_MODULEID = "ModuleID";
        public const string SQLCOL_APPLICATIONID = "ApplicationID";
        public const string SQLCOL_MODULENAME = "ModuleName";
        public const string SQLCOL_MODULEDISPLAYNAME = "ModuleDisplayName";
        public const string SQLCOL_DEVICES = "Devices";
        public const string SQLCOL_SUBSCRIPTDEVICES = "SubscriptDevices";
        public const string SQLCOL_TEMPLATEINFO = "TemplateInfo";
        public const string SQLCOL_DESCRIPTION = "Description";
        public const string SQLCOL_ADMINURL = "AdminUrl";
        public const string SQLCOL_SENDTYPE = "SendType";
        #endregion


        #region Contructors
        /// <summary>
        /// Construct empty entity
        /// </summary>
        public Module() { }

        /// <summary>
        /// Construct entity by primary key, other fields will be assigned by 
        /// "Load" method.
        /// </summary>
        public Module(Guid ModuleID)
        {
            this.ModuleID = ModuleID;
        }
        #endregion

        public override void Init(DataRow row)
        {
            ModuleID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_MODULEID]);
            ApplicationID = (Guid)ObjectType.GuidTypeHelper.Read(row[SQLCOL_APPLICATIONID]);
            ModuleName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_MODULENAME]);
            ModuleDisplayName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_MODULEDISPLAYNAME]);
            Devices = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_DEVICES]);
            SubscriptDevices = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_SUBSCRIPTDEVICES]);
            TemplateInfo = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_TEMPLATEINFO]);
            Description = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_DESCRIPTION]);
            AdminUrl = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ADMINURL]);
            SendType = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_SENDTYPE]);
        }

        #region Properties
        #region Property <Guid> ModuleID
        [Property("ModuleID", 16, SqlDbType.UniqueIdentifier, false, true)]
        public Guid ModuleID
        {
            get { return _ModuleID; }
            set { _ModuleID = value; }
        }
        private Guid _ModuleID = Guid.Empty;
        #endregion

        #region Property <Guid> ApplicationID
        [Property("ApplicationID", 16, SqlDbType.UniqueIdentifier, false, false)]
        public Guid ApplicationID
        {
            get { return _ApplicationID; }
            set { _ApplicationID = value; }
        }
        private Guid _ApplicationID = Guid.Empty;
        #endregion

        #region Property <string> ModuleName
        [Property("ModuleName", 100, SqlDbType.NVarChar, false, false)]
        public string ModuleName
        {
            get { return _ModuleName; }
            set { _ModuleName = value; }
        }
        private string _ModuleName = null;
        #endregion

        #region Property <string> ModuleDisplayName
        [Property("ModuleDisplayName", 100, SqlDbType.NVarChar, false, false)]
        public string ModuleDisplayName
        {
            get { return _ModuleDisplayName; }
            set { _ModuleDisplayName = value; }
        }
        private string _ModuleDisplayName = null;
        #endregion

        #region Property <int> Devices
        [Property("Devices", 4, SqlDbType.Int, false, false)]
        public int Devices
        {
            get { return _Devices; }
            set { _Devices = value; }
        }
        private int _Devices = int.MinValue;
        #endregion

        #region Property <int> SubscriptDevices
        [Property("SubscriptDevices", 4, SqlDbType.Int, false, false)]
        public int SubscriptDevices
        {
            get { return _SubscriptDevices; }
            set { _SubscriptDevices = value; }
        }
        private int _SubscriptDevices = int.MinValue;
        #endregion

        #region Property <string> TemplateInfo
        [Property("TemplateInfo", 2147483646, SqlDbType.NText, false, false)]
        public string TemplateInfo
        {
            get { return _TemplateInfo; }
            set { _TemplateInfo = value; }
        }
        private string _TemplateInfo = null;
        #endregion

        #region Property <string> Description
        [Property("Description", 2147483646, SqlDbType.NText, false, false)]
        public string Description
        {
            get { return _Description; }
            set { _Description = value; }
        }
        private string _Description = null;
        #endregion

        #region Property <string> AdminUrl
        [Property("AdminUrl", 2147483646, SqlDbType.NText, false, false)]
        public string AdminUrl
        {
            get { return _AdminUrl; }
            set { _AdminUrl = value; }
        }
        private string _AdminUrl = null;
        #endregion

        #region Property <int> SendType
        [Property("SendType", 4, SqlDbType.Int, false, false)]
        public int SendType
        {
            get { return _SendType; }
            set { _SendType = value; }
        }
        private int _SendType = int.MinValue;
        #endregion
        #endregion




    }
}
